package com.ruoyi.web.controller.tool;

import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.sign.Md5Utils;
import com.ruoyi.common.utils.wx.HttpClientSslUtils;

import java.util.HashMap;

public class Test11 {


    public static void main(String[] args) {
        double t1= (7.0)/100.0;
        System.out.println(t1);
        Double commission= Double.valueOf(1)*((7.0)/100.0);
        System.out.println(String.format("%.2f", commission));
    }

    public static void main1(String[] args) {

        String amount="0.01";
        String terminalCode="10806301";
        String key="70609712";
        String nonceStr="pFUuICf7GFHUGaAkiaWE5ZZNVRQzvNFy";
        String orderNumber="15";
        String payParams ="amount=" +amount+
                "&nonceStr=" +nonceStr+
                "&notifyUrl=http://test.dpdzsw.com/prod-api/ax/axRechargeR/wxPayNotifyecord" +
                 "&outTradeNo="+orderNumber+
                "&terminalCode=" +terminalCode+
                "&key="+key;
        // &terminalCode=10806301&key=70609712
        String sign = Md5Utils.toHex(Md5Utils.md5(payParams));

        HashMap<String, Object> params = new HashMap<>();
        params.put("terminalCode",terminalCode);
        params.put("nonceStr",nonceStr);
        params.put("notifyUrl","http://test.dpdzsw.com/prod-api/ax/axRechargeR/wxPayNotifyecord");
        params.put("outTradeNo",orderNumber);
        params.put("sign",sign);
        params.put( "amount",amount);
        ObjectMapper objectMapper = new ObjectMapper();
        String jsonString = null;
        try {
            jsonString = objectMapper.writeValueAsString(params);
            String resultStr = HttpClientSslUtils.doPost("https://www.yqdfpay.com/api/third/v2.0/pay/scheme", jsonString);
            /// String resultStr = HttpClientSslUtils.doPost("https://www.yqdfpay.com/api/third/v2.0/pay/qr", jsonString);
            System.out.println(resultStr);
            JSONObject object = JSONObject.parseObject(resultStr);
            System.out.println(object.get("openLink").toString());
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
